package priv.conceit.study.book.thread.chapter3.parts4;

/**
 * 3.4
 * 线程id
 * <p>
 * 线程id为唯一id
 * 从0开始自增
 * {@link Thread#getId()}
 * <p>
 * <p>
 * jvm在启动过程中，实际上已经开辟了许多线程
 * 所以自定义的线程并不是从0 开始的
 *
 * @author Conceit
 * @since 1.0.0, 2019/6/18
 */
public class Id {

	public static void main(String[] args) {
		getId();
	}

	public static void getId() {

		Thread t1 = new Thread(() -> {
			Thread t2 = new Thread(() -> System.out.println(Thread.currentThread().getName() + "<--->" + Thread.currentThread().getId()));
			t2.setName("t2");
			t2.start();

			System.out.println(Thread.currentThread().getName() + "<--->" + Thread.currentThread().getId());
		});

		t1.setName("t1");
		t1.start();

	}


}
